/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package coverter;

import entities.Prioridad;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author Agapo
 */
 @FacesConverter("prioridadConverter")
public class PrioridadConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Prioridad p=new Prioridad();
        String cad[]=value.split("__");
        p.setIdPrioridad(Integer.parseInt(cad[0]));
        p.setPrioridad(cad[1]);
        return p;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        Prioridad p=(Prioridad)value;
        String cad=p.getIdPrioridad()+"__"+p.getPrioridad();
        return cad;
    }
    
}
